package action.borrowinfo;

import java.io.IOException;
import java.util.Date;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


import bizlogic.borrowinfo.BorrowInfoService;
import bizlogic.borrowinfo.domain.BorrowInfo;

@WebServlet("/borrowinfoeditaction")
public class BorrowinfoEditAction extends HttpServlet {
	private static final long serialVersionUID = 1L;
    BorrowInfoService borrowInfoService=new BorrowInfoService();   

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		updateBorrowInfo(request, response);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}
	
	/*
     * 功能需求：实例化一个Borrowinfo实体，调用service层的相关方法，更新借书信息
     */
	public void updateBorrowInfo(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String borrowid=request.getParameter("data");
		BorrowInfo borrowInfo = borrowInfoService.queryBorrowInfoByID(borrowid);
		borrowInfo.setReturntime(new Date());
		String string=borrowInfoService.updateBorrowInfo(borrowInfo);
		response.getWriter().write(string);
	}

}
